package base;

/**
 * 内部类属性屏蔽
 *
 * @author liweimin
 * @date 2021/5/29 10:13
 * @since
 */
public class ShadowTest {
    public int x = 0;

    class FirstLevel {
        public int x = 1;

        void method(int x) {
            //method参数x屏蔽了FirstLevel类的成员变量x
            System.out.println("x = " + x);
            //使用this关键字调用成员变量访问x
            System.out.println("this.x = " + this.x);
            //使用类名+关键字 访问外部类的成员变量x
            System.out.println("ShadowTest1.this.x = " + ShadowTest.this.x);
        }
    }

    public static void main(String[] args) {
        ShadowTest shadowTest = new ShadowTest();
        shadowTest.new FirstLevel().method(34);
    }
}
